﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
using Workflow2211A.Consol.Data;
using Workflow2211A.Consol.Steps;
using WorkflowCore.Interface;

namespace Workflow2211A.Consol.Workflows
{
    public class WhileWorkflow : IWorkflow<LoopData>
    {
        public string Id => nameof(WhileWorkflow);

        public int Version => 1;

        public void Build(IWorkflowBuilder<LoopData> builder)
        {
            //NotImplementedException为实现的异常
            builder.StartWith<StartStep>()
                   .While(data => data.LoopCount <= 4)
                   .Do(x =>
                   {
                       x.Then<WhileStep>(step => 
                       {
                           step.Input(s => s.LoopData, data => data.LoopCount);
                           step.Output(data => data.LoopCount, s => s.LoopData);
                       });
                   }).Then<EndStep>();
        }
    }
}
